home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / com_and3.zip / DIAL.CMD < prev    next >
OS/2 REXX Batch file  |  1989-10-09  |  4KB  |  135 lines

  1. ; ----- COM-AND dial a string of any width
  2. ; -----------------------------------
  3. ;    This script dials a string of any width, and performs the Alt-R
  4. ;    function, waiting for connect or redial.
  5. ;
  6. ;    The value in S0, if supplied, establishes the number being dialed.
  7. ;    Modem speed, parity, data and stop bits must be set by the caller.
  8. ;
  9. ;    Script: R.McG, commenced 9/89
  10. ; -----------------------------------
  11. ;
  12. ;    If number is not supplied, query for it
  13. ;
  14. IF NULL S0            ; Not passed as parm
  15.    WOPEN 10,1, 13,77 (contrast) Exit
  16.    ATSAY 11, 3 (contrast) "Enter the number to be dialed:"
  17.    ATSAY 12, 3 (contrast) "->"
  18.    ATSAY 13,26 (contrast) " Press ESC to exit"
  19.    ATGET 12,6  (contrast) 60 S0
  20.    WCLOSE            ; Restore screen under
  21.    IF NULL S0            ; Null entry terminates script
  22.       GOTO EXIT         ; No-op
  23.       ENDIF
  24.    ENDIF
  25. GOTO Start
  26. ;
  27. ;    Successful connection
  28. ;
  29. Done:
  30.    CLOG "DIAL.CMD connect: "*S0
  31.    WCLOSE            ; Close open window
  32.    SET SUCCESS ON        ; Report success
  33.    SET RDISP ON         ; Restore display
  34.    IF FCALLED FRETURN
  35.    EXIT
  36. ;
  37. ;    Failed DIAL
  38. ;
  39. Unavailable:
  40.    HANGUP
  41.    WCLOSE            ; Close open window
  42.    SET SUCCESS OFF        ; Report success
  43.    SET RDISP ON         ; Restore display
  44.    IF FCALLED FRETURN
  45.    EXIT
  46. ;
  47. ;    General exit (modem not connected yet)
  48. ;
  49. Exit:
  50.    WCLOSE            ; Close open window
  51.    SET RDISP ON         ; Restore display
  52.    SET SUCCESS OFF        ; Report success
  53.    IF FCALLED FRETURN
  54.    EXIT
  55. ;
  56. ;    Initialize values
  57. ;
  58. Start:
  59.    TIME S1            ; Redial sequaence start
  60.    S2 = S1            ; THis attempt start
  61.    S3 = S1            ; TIme now
  62.    S4 = ""                      ; Modem return string
  63.    N0 = 1            ; Attempt #
  64.    N1 = "_RDelay"               ; Redial delay
  65.    RFLUSH            ; Clear modem buffer
  66.    SET RDISP OFF        ; Don't display
  67. ;
  68. ;    Open a window to show progress
  69. ;
  70.    WOPEN  5,10 14,70 (default) Unavailable
  71.    ATSAY  5,12 (default) " COM-AND Connect (script) "
  72.    ATSAY  7,12 (default) "Number: "*S0(0:50)
  73.    ATSAY  8,12 (default) "Redial Started: "*S1
  74.    ATSAY  9,12 (default) "Call started:   "*S2
  75.    ATSAY 10,12 (default) "Call #:         "*N0
  76.    ATSAY 11,12 (default) "Call delay:     "*N1
  77.  
  78.    ATSAY  9,40 (default) "Time now:       "*S3
  79.    ATSAY 11,40 (default) "Modem: "*S4(0:20)
  80.  
  81.    ATSAY 13,12 (default) "Press space bar to cycle; ESC to cancel"
  82. ;
  83. ;    Hangup, and transmit the dialing cmd
  84. ;
  85. Loop:
  86.    TIME S2            ; Set current time
  87.    ATSAY  9,28 (default) S2    ; Display time
  88.    ATSAY 10,28 (default) N0    ; Display attempt #
  89.    ATSAY 10,40 (default) "Hanging up"
  90.    TRANSMIT "_MESCa"&""         ; Wake up the modem
  91.    TRANSMIT "_MHANg"&""         ; Hangup
  92.  
  93.    ATSAY 10,40 (default) "Dialing   "
  94.    PAUSE 5            ; Wait for modem to clear
  95.    TRANS "_DPRE"& S0& ""& "_DSUF"& ""   ; Ensure trailing blanks deleted
  96. ;
  97. ;    Wait for a response from the modem
  98. ;
  99.    ATSAY 10,40 (default) "Waiting   "
  100.    SET TIMER (0)
  101. Waiting:
  102.    TIME S3            ; Set current time
  103.    ATSAY  9,56 (default) S3    ; Display time
  104.    IF HITKEY GOTO Keyhit    ; Skip if
  105.  
  106.    RGET S5 1 1            ; Wait for one char one sec
  107.    IF SUCCESS            ; We have a char
  108.       IF NULL S5        ; a c/r rtnd
  109.      S4 = ""                ; Clear rcv string
  110.      ATSAY 11,47 (default) "                     "
  111.       ELSE
  112.      S4 = S4*S5
  113.      IF FIND S4 "_MCONN"&"" GOTO Done
  114.      ENDIF
  115.       ENDIF
  116.  
  117.    ATSAY 11,47 (default) S4(0:20)
  118.    TSINCE (0) N2,N3,N4
  119.    N3 = N3*60+N2        ; Total # secs
  120.    IF LT N3 N1 GOTO Waiting    ; If delay not exceeded
  121.  
  122.    INC N0            ; Count the try
  123.    GOTO Loop            ; Start new attempt
  124. ;
  125. ;    Keypress is pending
  126. ;
  127. Keyhit:
  128.    KEYGET S5            ; Read kbd
  129.    IF STRCMP S5 " "             ; Space bar
  130.       INC N0            ; Count last attempt
  131.       GOTO Loop         ; .. start new cycle
  132.       ENDIF
  133.    SOUND 100,100        ; Indicate failed
  134.    GOTO Waiting         ; Continue otherwise
  135.